/*
https://leetcode.cn/problems/maximum-of-absolute-value-expression/solution/python-jie-fa-bao-li-shu-xue-by-jiayangwu/
 */
import java.util.Arrays;

public class Solution1131 {
    public int maxAbsValExpr(int[] arr1, int[] arr2) {
        int[][] f=new int[4][arr1.length];
        for (int i=0;i<arr1.length;i++){
            f[0][i]=arr1[i]+arr2[i]+i;
            f[1][i]=arr1[i]-arr2[i]+i;
            f[2][i]=arr1[i]+arr2[i]-i;
            f[3][i]=arr1[i]-arr2[i]-i;
        }
        int a= Arrays.stream(f[0]).max().getAsInt()-Arrays.stream(f[0]).min().getAsInt();
        int b= Arrays.stream(f[1]).max().getAsInt()-Arrays.stream(f[1]).min().getAsInt();
        int c= Arrays.stream(f[2]).max().getAsInt()-Arrays.stream(f[2]).min().getAsInt();
        int d= Arrays.stream(f[3]).max().getAsInt()-Arrays.stream(f[3]).min().getAsInt();
        return Math.max(a,Math.max(b,Math.max(c,d)));
    }

    public static void main(String[] args) {
        System.out.println(new Solution1131().maxAbsValExpr(new int[]{1,2,3,4},new int[]{-1,4,5,6}));
    }
}
